<?php

header('content-type:text/html;charset:utf-8');
 $link=mysqli_connect('localhost','root','');
if(!$link){
    die('数据库连接失败'.mysqli_error());
}
/*mysqli_querry($link,'set name utf8');
mysqli_querry($link,'use itcast');
define('APP','itcast');
require './List_html.php';*/
$fields=array('e_dept','date_of_entry');
$sql_order='';
$order=isset($_GET['order'])?$_GET['order']:'';
$sort=isset($_GET['sort'])?$_GET['sort']:'';
if(in_array($order,$fields))
{
    if($sort=='desc'){
        $sql_order="order by $order des";
        $sort='asc';
    }else{
        $sql_order="order by $order asc";
        $sort='desc';
    }
}
$sql='select from emp_info $sql_order';
$result=mysqli_query($link,$sql);
$emp_info= array();
while($row = mysqli_fetch_assoc($result))
{
    $emp_info[] = $row;
}
define('APP','itcast');
require './list_html.php';
